<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>页面增删改查功能添加页面</title>
<script type="text/javascript" src="${path}/js/scripts/bootstart.js"></script>
<link rel="stylesheet" type="text/css" href="${path}/css/focus.css" />
</head>
<body>
	<form id="functionForm" method="post">
		<input name="functionId" class="mini-hidden" id="functionId" />
			<div style="padding: 5px;">
				<table width="540" height="172" border="0">
					<tr>
						<td width="80" height="30" scope="row">功能名称:</td>
						<td width="334"><input name="functionName"
							required="true" class="mini-textbox" style="width: 90%;" vtype="maxLength:30"/> <font
							color="#ff0000">*</font></td>
						<td width="120">&nbsp;</td>
					</tr>
					<tr>
						<td height="33" scope="row">功能key:</td>
						<td><input id="code" name="code" required="true"
							class="mini-textbox" style="width: 90%;"  vtype="maxLength:30"/> <font
							color="#ff0000">*</font></td>
						<td>&nbsp;</td>
					</tr>
					<tr>
						<td height="66" scope="row">描述:</td>
						<td><input name="remark" class="mini-textarea"
							style="width: 90%; height: 50%;"  vtype="maxLength:255"/></td>
						<td>&nbsp;</td>
					</tr>
				</table>
			</div>
		<div style="text-align: center; padding: 10px;">
			<a class="mini-button" onclick="addform.saveData"
				style="width: 60px; margin-right: 20px;">保存</a> <a
				class="mini-button" onclick="$.form.onCancel()" style="width: 60px;">取消</a>
		</div>
	</form>
</body>
<script type="text/javascript" src="${path}/js/scripts/dataform.js"></script>
<script type="text/javascript">
	mini.parse();
	var target = "";//修改信息时记录功能key
	$(function() {
		$.form.init(); //初始化表单
		window.addform = {};
		addform.saveData = function() {
			var code = mini.get("code").value;
			var fid = mini.get("functionId").value;
			if (fid != null && fid > 0 && code == target) {
				$.form.saveData({
					url : "${path}/function/mgr/addFunction",
					id : "functionForm",
					showMsg : true
				});
			} else {
				$.ajax({
					url : "${path}/function/mgr/veriKey",
					cache : false,
					post : "post",
					data : "code=" + code,
					success : function(obj) {
						if (obj == "true") {
							mini.alert("功能代码已经存在,不能重复！");
							return;
						} else {
							$.form.saveData({
								url : "${path}/function/mgr/addFunction",
								id : "functionForm",
								showMsg : true
							});
						}
					}
				});
			}
		};
	});
	/**
	 * 表单加载成功时执行函数
	 * @param {Object} tform
	 */
	$.form.loadFormSuccess = function(tform) {
		target = mini.get("code").value;
	};
</script>
</html>